package gui.windows.components;

import java.awt.Color;
import java.awt.Component;
import java.io.File;

import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

@SuppressWarnings({ "serial", "rawtypes" })
public class FileCellRenderer extends JLabel implements ListCellRenderer {

	@Override
	public Component getListCellRendererComponent(JList list, Object value,
			int index, boolean isSelected, boolean cellHasFocus) {

		File file = (File) value;
		String name = file.getName().substring(0, file.getName().lastIndexOf("."));
		this.setText(name);

		this.setOpaque(true);
		
		if(isSelected){
			this.setForeground(Color.white);  
			this.setBackground(Color.black);
		}
		else{
			this.setForeground(Color.black);  
			this.setBackground(Color.white);
		}

		return this;
	}


}
